/**
 * 文章相关的接口
 */
import request from '@/utils/request'

/**
 * 获取文章列表
 * @param {*} params 
 */
export const getArticles = params => {
    return request({
        method: 'GET',
        url: '/mp/v1_0/articles',
        params: params
    })
}

/**
 * 获取频道列表
 */
export const getArticleChannel = () => {
    return request({
        method: 'GET',
        url: '/mp/v1_0/channels'
    });
}


/**
 * 删除文章
 * @param {*} delId 
 */
export const delArticle = delId => {
    return request({
        method: 'DELETE',
        url: `/mp/v1_0/articles/${delId}`
    });
}

/**
 * 新建文章
 */
export const addArticle = (data, draft = false) => {
    return request({
        method: 'POST',
        url: '/mp/v1_0/articles',
        params: {
            draft: draft
        },
        data: data
    })
}

/**
 * 修改文章
 */
export const updateArticle = (articleId, data, draft = false) => {
    return request({
        method: 'PUT',
        url: `/mp/v1_0/articles/${articleId}`,
        params: {
            draft: draft
        },
        data: data
    })
}

/**
 * 获取指定文章
 */
export const getByIdArticle = articleId => {
    return request({
        method: 'GET',
        url: `/mp/v1_0/articles/${articleId}`
    })
}